﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Web;
using Business.Common.Exception;
using Business.Common.QueryModel;
using Business.Domain.Warehouse;
using Business.Domain.Inventory;

namespace Business.Service.Contract
{
    [ServiceContract(SessionMode = SessionMode.NotAllowed)]
    public interface IInboundService
    {
        #region inbound plan
        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebInvoke(UriTemplate = "InboundPlan/GetByQuery", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        List<InboundPlan> GetInboundPlanByQuery(Query query);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebInvoke(UriTemplate = "InboundPlan/GetByPagerQuery", Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        List<InboundPlan> GetInboundPlanByPagerQuery(PagerQuery query, out int qty);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebGet(UriTemplate = "InboundPlan/GetByCode?warehouseCode={warehouseCode}&planNumber={planNumber}")]
        InboundPlan GetInboundPlanByNumber(string warehouseCode, string planNumber);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebInvoke(UriTemplate = "InboundPlan/Create", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        InboundPlan CreateInboundPlan(InboundPlan inboundPlan);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebInvoke(UriTemplate = "InboundPlan/Update", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        bool UpdateInboundPlan(InboundPlan inboundPlan);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebGet(UriTemplate = "InboundPlan/Revoke?InboundPlanId={inboundPlanId}")]
        bool RevokeInboundPlan(long inboundPlanId);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebGet(UriTemplate = "InboundPlan/Confirm?warehouseId={warehouseId}&planId={planId}&userId={userId}")]
        bool ConfirmInboundPlan(int warehouseId, long planId, int userId);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebInvoke(UriTemplate = "InboundPlan/AddDetail", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        int AddInboundPlanDetail(long inboundPlanId, InboundPlanDetail planDetail);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebInvoke(UriTemplate = "InboundPlan/UpdateDetail", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        bool UpdateInboundPlanDetail(InboundPlanDetail planDetail);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebGet(UriTemplate = "InboundPlan/RemoveDetail?planDetailId={planDetailId}")]
        bool RemoveInboundPlanDetail(long planDetailId);
        
        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebInvoke(UriTemplate = "InboundPlan/Import?clientCode={clientCode}", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        bool ImportInboundPlan(string clientCode, string message);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebGet(UriTemplate = "InboundPlan/GetDetails?planDetailId={planDetailId}")]
        List<InboundPlanDetail> GetInboundPlanDetails(long planDetailId);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebGet(UriTemplate = "InboundPlan/GetBillsByPlan?planDetailId={planDetailId}")]
        List<InboundBill> GetInboundBillsByPlan(long planDetailId);

        [OperationContract]
        [FaultContract(typeof(ServiceError))]
        [WebGet(UriTemplate = "InboundPlan/GetSerialNumbersByPlan?planDetailId={planDetailId}")]
        List<SerialNumber> GetSerialNumbersByPlan(long planDetailId);
        #endregion

        #region inbound bill
        //[OperationContract]
        //[FaultContract(typeof(ServiceError))]
        //bool CreateReceivingTask(long inboundPlanId, )
        #endregion
    }
}
